package de.baumann.browser.api.net.vo.duobao

import android.content.Context
import com.contrarywind.interfaces.IPickerViewData
import java.io.BufferedReader
import java.io.InputStreamReader

class Address {
    var addressInfo = ""
    var address = ""
    var phone = ""
    var name = ""
}

data class PCACodePO(
        val code: String,
        val name: String,
        val children: MutableList<CCodePO>
)

//存放市以及所属辖区
data class CCodePO(
        val code: String,
        val name: String,
        val children: MutableList<AddressInfoPO>
)

//用于显示PickerView显示
data class AddressInfoPO(
        //地区编码
        val code: String,
        //地区名称
        val name: String
) : IPickerViewData {
    override fun getPickerViewText(): String = name
}

fun getAssetsFileText(context: Context, fileName:String):String{
    val strBuilder=StringBuilder()
    val am=context.assets
    val inputStream = am.open("area.json")
    BufferedReader(InputStreamReader(inputStream)).use {
        while (true) {
            val line = it.readLine() ?: break //当有内容时读取一行数据，否则退出循环
            strBuilder.append(line)
        }
    }

    return strBuilder.toString()
//  适用于单行文件
//    val bf = BufferedReader(InputStreamReader(assetManager.open(fileName)))
//    bf.use { strBuilder.append(it.readLine())}
//    bf.close()
//    return strBuilder.toString()
}